package bis;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FLOrderMgr extends FLBaseMgr {

    private ArrayList GetDate() {
        ArrayList list = new ArrayList();
        ResultSet rs = super.Query();
        try {
            while (rs.next()) {
                FLOrder flo = new FLOrder(0, rs.getDouble(1), rs.getDouble(2), rs.getDouble(3), rs.getDouble(4), rs.getDouble(5), rs.getString(6));
                list.add(flo);
            }
        } catch (SQLException ex) {
            Logger.getLogger(FLOrderMgr.class.getName()).log(Level.SEVERE, null, ex);
        }

        return list;
    }

    public ArrayList GetDateById(String id) {
        QueryStr = "select * from tblOrders where Id='" + id + "'";
        return GetDate();
    }

    public ArrayList GetAllDate() {
        QueryStr = "select * from tblOrders";
        return GetDate();
    }

    public void flcdelete(String id) {
        this.bm = id;
        this.BaseDelete();

    }

    public boolean isInsert(FLOrder flo) {

        InsertStr = "insert into tblOrders(Yhbm,Yf,Sf,qz,Zl,status) values(" + flo.Yhbm + "," + flo.Yf + "," + flo.Sf + "," + flo.qz + "," + flo.Zl + ",'" + flo.status + "')";
        return Insert();
    }

    public void setUpdate(FLOrder flo) {
        QueryStr = "select * from tblOrders where Id='" + flo.Id + "'";
        super.UpdateStr = "update tblOrders set Yhbm=" + flo.Yhbm + ",Yf=" + flo.Yf + ",Sf=" + flo.Sf + ",qz=" + flo.qz + ",Zl=" + flo.Zl + ",status='" + flo.status + "' where Id=" + flo.Id;
        super.BaseUpdate();
    }

    @Override
    public void BaseDelete() {
        QueryStr = "select * from tblOrders where Id=" + bm;
        UpdateStr = "delete from tblOrders where Id=" + bm;
        super.BaseDelete();
    }

    public static void main(String[] args) {
        FLOrder c = new FLOrder();
        c.setQz(1);
        c.setSf(2);
        c.setStatus("ok");
        c.setYf(3);
        c.setZl(4);
        c.Yhbm = 5;
        c.Id = 3;
        FLOrderMgr c2 = new FLOrderMgr();
        //c2.isInsert(c);
        c.setQz(10.2345);
        c2.setUpdate(c);
    }
}

